package com.ctg.payroll2.dao.payment.impl;

import java.sql.SQLException;
import java.util.List;

import com.ctg.payroll2.bean.filter.PayClassFilter;
import com.ctg.payroll2.bean.po.PayClass;
import com.ctg.payroll2.dao.payment.PayClassDAO;
import com.ctg.platform.orm.ibatis.IbatisEntityDao;
import com.ctg.platform.util.Page;

@SuppressWarnings("unchecked")
public class PayClassDAOImpl extends IbatisEntityDao<PayClass> implements
		PayClassDAO {
	public Long insertPayClazz(PayClass payClass){
		Long l = new Long(0);
		try {
			l = (Long)getSqlMapClient().insert(getNameSpace() + ".insertPayClass", payClass);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return l;
	}
	public Page queryPayClazzPageByFilter(PayClassFilter filter) {
		return pagedQueryByFilter(this.getClass(), filter,
				".queryPayClassPageByFilter_count",
				".queryPayClassPageByFilter_query");
	}

	public List<PayClass> queryForPayClazzById(Long id) {
		return getSqlMapClientTemplate().queryForList(getNameSpace() + ".queryForPayClass", id);
	}
	
	public void fakeDeletePayClazzByIds(PayClass pay){
		getSqlMapClientTemplate().update(getNameSpace() + ".fakeDeletePayClazzById", pay.getPay_class_id());
	}

	public int getEmployeeByPayClazzId(Long id) {
		return (Integer)getSqlMapClientTemplate().queryForObject(getNameSpace() + ".getEmployeeByPayClassId", id);
	}
	public void updatePayClazz(PayClass payClazz) throws SQLException{
		if (payClazz==null) {
			return;
		}
		getSqlMapClient().update(getNameSpace() + ".updatePayClazz", payClazz);
	}
	
	
	
	
	
	
	
	private String getNameSpace(){
		return this.getClass().getSimpleName();
	}
	public List<PayClass> getNotExistInPaySumClassById(PayClass payClass) {
		// TODO Auto-generated method stub
		return getSqlMapClientTemplate().queryForList(getNameSpace() + ".getNotExistInPaySumClassById",payClass);
	}
}
